#!/usr/bin/env sh

sudo yabai --load-sa
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"

# global settings
yabai -m config mouse_follows_focus off
yabai -m config focus_follows_mouse off
yabai -m config window_origin_display default
yabai -m config window_placement second_child
yabai -m config window_topmost off
yabai -m config window_shadow float
yabai -m config window_opacity on
yabai -m config window_opacity_duration 0.15
yabai -m config active_window_opacity 0.95
yabai -m config normal_window_opacity 0.85
yabai -m config window_border on
yabai -m config window_border_width 4
yabai -m config active_window_border_color 0xff8CABC8
yabai -m config normal_window_border_color 0xff2a2f38
yabai -m config insert_feedback_color 0xff9dd274
yabai -m config split_ratio 0.50
yabai -m config auto_balance off
yabai -m config mouse_modifier alt
yabai -m config mouse_action1 move
yabai -m config mouse_action2 resize
yabai -m config mouse_drop_action swap
yabai -m config external_bar all:53:0

# signal with sketchybar
yabai -m signal --add event=window_focused action="sketchybar --trigger window_focus"
yabai -m signal --add event=window_created action="sketchybar --trigger windows_on_spaces"
yabai -m signal --add event=window_destroyed action="sketchybar --trigger windows_on_spaces"

# general space settings
yabai -m config layout bsp
yabai -m config top_padding 8
yabai -m config bottom_padding 8
yabai -m config left_padding 8
yabai -m config right_padding 8
yabai -m config window_gap 8
# yabai -m config window_animation_duration    0.00

yabai -m rule --add app="^iStat*" sticky=on layer=above manage=off border=off
yabai -m rule --add app="^System Preferences*" manage=off

# disable specific apps
yabai -m rule --add app="^System Settings$" manage=off
yabai -m rule --add app="^Calculator$" manage=off
yabai -m rule --add app="^Preview$" manage=off
yabai -m rule --add app="^Karabiner-Elements$" manage=off
yabai -m rule --add app="^QuickTime Player$" manage=off
yabai -m rule --add app="^WeChat$" manage=off
yabai -m rule --add app="^HapiGo$" manage=off
yabai -m rule --add app="^360压缩大师$" manage=off
yabai -m rule --add app="^Font Book$" manage=off
yabai -m rule --add app="^NeatDownloadManager$" manage=off
yabai -m rule --add app="^NetEaseMusic$" manage=off
yabai -m rule --add app="^MonitorControl$" manage=off
yabai -m rule --add app="^Tencent Lemon$" manage=off
yabai -m rule --add app="^Kap$" manage=off border=off
yabai -m rule --add app="^Snipaste$" manage=off border=off
yabai -m rule --add app="^摸鱼单词$" manage=off border=off
# yabai -m rule --add app="^TencentMeeting$" manage=off

echo "yabai configuration loaded.."
